<template>
  <div class="container">
    <div class="app-container">
      <el-button type="primary">添加权限</el-button>
      <el-table :data="list" row-key="id" default-expand-all>
        <el-table-column label="名称" prop="name" />
        <el-table-column label="标识" prop="code" />
        <el-table-column label="描述" prop="description" />
        <el-table-column label="操作">
          <template #default="{row}">
            <el-button v-if="row.type ===1" type="text" size="mini">添加</el-button>
            <el-button type="text" size="mini">编辑</el-button>
            <el-button type="text" size="mini">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>
<script>
import { getPermsAPI } from '@/api/permission'
import { list2Tree } from '@/utils'
export default {
  name: 'Permission',
  data() {
    return {
      list: []
    }
  },
  created() {
    this.onLoad()
  },
  methods: {
    async  onLoad() {
      const { data } = await getPermsAPI()
      this.list = data.rows
      const tree = list2Tree(data, 0)
      this.list = tree
    }

  }
}
</script>
